package huizhi.net;

import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.charset.Charset;

public class SocketClient {
    public static void main(String[] args) throws Exception{
        System.out.println("我是SockerClient");

        //连接本机的8888端口
        Socket client = new Socket(InetAddress.getLocalHost(), 8888);
        //从套接字获取字节输入流
        OutputStream outputStream = client.getOutputStream();
        outputStream.write("hello".getBytes(Charset.defaultCharset()));

        outputStream.close();
        client.close();
    }
}
